local skel = fk.CreateSkill {
  name = "lb__fanghai",
}

Fk:loadTranslationTable {
  ["lb__fanghai"] = "妨害",
  --[":lb__fanghai"] = "当你失去最后一张手牌后，你可以弃置一名角色的一张牌，若你弃置的是武器牌或【杀】，你摸一张牌，否则本轮此技能失效。",
  --9.23
  [":lb__fanghai"] = "当你失去最后一张手牌后，你可以弃置一名角色的一张牌，若你弃置的是武器牌或伤害牌，你摸一张牌，否则本轮此技能失效。",

  ["#lb__fanghai"] = "妨害：你可以弃置一名角色的一张牌，若为武器牌或伤害牌，你摸一张牌，否则本轮此技能失效",

  ["$lb__fanghai1"] = "收网标记激活。",
  ["$lb__fanghai2"] = "接下来，就是愉快的反击时间了。",
}

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skel.name) or not player:isKongcheng() then return end
    for _, move in ipairs(data) do
      return move.from == player and table.find(move.moveInfo, function(info)
        return info.fromArea == Card.PlayerHand
      end) and table.find(player.room:getAlivePlayers(), function(p)
        return not p:isNude()
      end)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local ts = table.filter(room:getAlivePlayers(), function(p)
      return not p:isNude()
    end)
    if #ts == 0 then return end
    local tos = room:askToChoosePlayers(player, {
      targets = ts,
      min_num = 1,
      max_num = 1,
      prompt = "#lb__fanghai",
      skill_name = skel.name,
    })
    event:setCostData(self, { tos = tos })
    return #tos > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local t = event:getCostData(self).tos[1]
    local c = Fk:getCardById(room:askToChooseCard(player, {
      target = t,
      flag = "he",
      skill_name = skel.name,
    }))
    room:throwCard(c, skel.name, t, player)
    if c.sub_type == Card.SubtypeWeapon or c.is_damage_card then
      player:drawCards(1, skel.name)
    else
      room:invalidateSkill(player, skel.name, "-round")
    end
  end,
})

return skel